package dto.retjson;

import java.util.List;
import java.util.Map;

/**
 * User: yeh
 * Date: 5/7/13
 * Time: 12:42 AM
 * For:  wilddragon
 */
public class PageDataDto {
    public Integer totalPageNum;
    public List objects;

//    public String dataUrl;
//    public String pageParamKey;
//
//    //search box
//    public String searchParamKey;
//    public Boolean haveSearchBox;
//
//    //page widgets
//    public Map<String, String> widgets;

    public PageDataDto(Integer totalElementNum, Integer elementsPerPage, List objects) {
        this.totalPageNum = getTotalPageNum(totalElementNum, elementsPerPage);
        this.objects = objects;
    }
    private Integer getTotalPageNum(Integer totalElementsNum, Integer elementsPerPage){
        Integer totalPageNum = totalElementsNum / elementsPerPage;
        if(totalElementsNum % elementsPerPage != 0){
            ++totalPageNum;
        }
        return totalPageNum;
    }
}
